package com.brsya.movie.fragment;

import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.View;
import android.widget.RelativeLayout;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;

import com.brsya.base.base.BaseLayoutFragment;
import com.brsya.base.util.UiUtil;
import com.brsya.movie.R;
import com.bytedance.novel.pangolin.NovelSDK;
import com.bytedance.sdk.dp.DPSdk;
import com.bytedance.sdk.dp.DPWidgetNewsParams;
import com.bytedance.sdk.dp.IDPNewsListener;
import com.bytedance.sdk.dp.IDPWidget;

/**
 * Created by Brsya
 * CreateDate: 2022/7/25  18:33
 * Description:
 * 新闻
 */
public class BookFragment extends BaseLayoutFragment {


    private RelativeLayout rlNewsBox;
    private Handler mainHandler;
    private Runnable bookChangePaddingRunnable;


    public static BookFragment newInstance() {

        Bundle args = new Bundle();

        BookFragment fragment = new BookFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    protected void initView() {
        setContentViewId(R.layout.fragment_book);
        rlNewsBox = findViewById(R.id.rl_book_box);
    }

    @Override
    protected void initData() {


        mainHandler = new Handler(Looper.getMainLooper());

        Fragment fragment = NovelSDK.INSTANCE.getNovelFragment();

//        // 设置小说页面头部padding
//        mainHandler.postDelayed(bookChangePaddingRunnable = new Runnable() {
//            @Override
//            public void run() {
//                View rootView = fragment.getView();
//                if (rootView == null) {
//                    mainHandler.postDelayed(bookChangePaddingRunnable, 100);
//                    return;
//                }
//                rootView.setPadding(
//                        rootView.getPaddingLeft(),
//                        rootView.getPaddingTop() + UiUtil.getStatusBarHeight(getContext()),
//                        rootView.getPaddingRight(),
//                        rootView.getPaddingBottom()
//                );
//            }
//        }, 100);


        FragmentTransaction fragmentTransaction = getChildFragmentManager().beginTransaction();
        fragmentTransaction.add(R.id.rl_book_box, fragment);
        fragmentTransaction.commit();
    }
}
